<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算任意数的阶乘</title>
</head>
<body>
    <script>
        function fun (a){

        // 定义一个变量res接收阶乘计算结果
        var res =1
        for (i=a;i>0;i--){
            res *= i
        }
        console.log(res);
    }

    // 调用，传参
    fun (10);
    fun (20);
    </script>
</body>
</html>